home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PASCAL
/
0195.ZIP
/
HEXFUNCT.LIB
< prev
next >
Wrap
Text File
|
1984-12-02
|
1KB
|
42 lines
{@@@@@@@@@@@ copyright (C) 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@
The purchaser of these procedures and functions may include them in COMPILED
programs freely, but may not sell or give away the source text.}
type HexString = string[5];
{@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
function Hex(num:integer):HexString;
{-----------------------------------------------------------}
function RealMod(RealNum:real;ModBy:integer):integer;
var
this, that : real; {A MODULO function for numbers}
begin {too big to be integers. }
this := trunc(realnum/modby);
that := ModBy*this;
RealMod := trunc(RealNum - that);
end;
{-----------------------------------------------------------}
function hexchar(N:byte):char;
begin
if N < 10 then hexchar := chr(N+48)
else hexchar := chr(N+55);
end;
{-----------------------------------------------------------}
var
RealNum : real;
N, M : byte;
temp : Hexstring;
begin
temp := ' ';
if num < 0 then RealNum := (65536. + num)
else RealNum := num;
for N := 5 downto 2 do
begin
M := RealMod(RealNum,16);
RealNum := trunc(RealNum/16);
temp[N] := hexchar(M);
end;
temp[1] := '$';
Hex := temp;
end;
{@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}